package com.ruoyi.web.controller.openapi;


import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.*;
import com.ruoyi.yanjing.domain.req.LineDevicePointTemperatureReq;
import com.ruoyi.yanjing.domain.vo.LineDevicePointTemperatureVo;
import com.ruoyi.yanjing.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("聚合查询管理")
@RestController
@RequestMapping("/openapi/query")
public class OpenApiController extends BaseController {

    @Autowired
    private IDeviceTemperatureService deviceTemperatureService;

    @Autowired
    private IMonitorPointService monitorPointService;

    @Autowired
    private IAreaService areaService;

    @Autowired
    private ILineService lineService;


    @Autowired
    private IElectricityPoleService electricityPoleService;


    //===========地图页面======start======================
    /**
     * 地图页面：查询区域列表-不分页
     */
    @ApiOperation("地图页面-温度页面：查询区域列表-不分页")
    @GetMapping("/selectAllAreaList")
    public AjaxResult selectAllAreaList(Area area)
    {
        return success(areaService.selectAreaList(area));
    }



    /**
     * 地图页面：查询线路列表-不分页
     */
    @ApiOperation("地图页面-温度页面：查询线路列表-不分页")
    @GetMapping("/selectAllLineList")
    public AjaxResult selectAllLineList(Line line)
    {
        return success(lineService.selectLineList(line));
    }



    /**
     * 地图页面：查询电杆及线路信息列表-不分页
     */
    @ApiOperation("地图页面-告警页面：查询电杆信息-不分页")
    @GetMapping("/selectAllElectricityPoleAndLineInfoList")
    public AjaxResult selectAllElectricityPoleAndLineInfoList(ElectricityPole electricityPole)
    {
        return success(electricityPoleService.selectElectricityPoleAndLineInfoList(electricityPole));
    }


    //===========地图页面======end======================

    //===========温度页面======start======================
    /**
     * 获取区域详细信息
     */
    @ApiOperation("温度页面：获取区域详细信息")
    @GetMapping(value = "/getInfoByAreaCode/{code}")
    public AjaxResult getInfoByAreaCode(@PathVariable("code") String code)
    {
        return success(areaService.getInfoByAreaCode(code));
    }


    /**
     * 查询电杆信息列表-不分页
     */

    @GetMapping("/selectAllPoleList")
    @ApiOperation("温度页面：查询电杆信息列表-不分页")
    public AjaxResult selectAllPoleList(ElectricityPole electricityPole)
    {
        return success(electricityPoleService.selectElectricityPoleList(electricityPole));
    }


    /**
     * 获取电杆信息详细信息
     */
    @ApiOperation("温度页面：获取电杆信息详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(electricityPoleService.selectElectricityPoleById(id));
    }


    /**
     * 查询监测点位设备所有信息列表-不分页
     */
    @ApiOperation("温度页面：查询监测点位设备所有信息列表-不分页")
    @GetMapping("/selectAllPointDeviceList")
    public AjaxResult selectAllPointDeviceList(MonitorPoint monitorPoint)
    {
        return success(monitorPointService.selectAllPointDeviceList(monitorPoint));
    }

    /**
     * 查询温度日志列表-不分页
     */
    @ApiOperation("温度页面：查询温度日志列表-不分页")
    @GetMapping("/selectAllTemperatureList")
    public AjaxResult selectAllTemperatureList(DeviceTemperature deviceTemperature)
    {
        return success(deviceTemperatureService.selectAllTemperatureList(deviceTemperature));
    }
    //===========温度页面======end======================


    //===========告警页面======start======================

    /**
     * 告警页面：查询区域线路信息列表
     */
    @ApiOperation("告警页面：查询区域线路信息列表")
    @GetMapping("/selectLineAndAreaInfoList")
    public TableDataInfo selectLineAndAreaInfoList(Line line)
    {
        startPage();
        List<Line> list = lineService.selectLineAndAreaInfoList(line);
        return getDataTable(list);
    }

    /**
     * 查询电杆及线路信息列表
     */
    @ApiOperation("告警页面：查询电杆及线路信息列表")
    @GetMapping("/selectElectricityPoleAndLineInfoList")
    public TableDataInfo selectElectricityPoleAndLineInfoList(ElectricityPole electricityPole)
    {
        startPage();
        List<ElectricityPole> list = electricityPoleService.selectElectricityPoleAndLineInfoList(electricityPole);
        return getDataTable(list);
    }

    /**
     * 查询监测点位线路电杆信息列表
     */
    @ApiOperation("告警页面-查询告警信息列表")
    @GetMapping("/selectAbnormalMonitorPointAndLinePoleInfoList")
    public TableDataInfo selectAbnormalMonitorPointAndLinePoleInfoList(MonitorPoint monitorPoint)
    {
        startPage();
        List<MonitorPoint> list = monitorPointService.selectAbnormalMonitorPointAndLinePoleInfoList(monitorPoint);
        return getDataTable(list);
    }
    //===========告警页面======end======================


    //===========传感器页面======start======================
    /**
     * 查询监测点位线路电杆信息列表
     */
    @ApiOperation("传感器页面-查询监测点位线路电杆信息列表")

    @GetMapping("/selectMonitorPointAndLinePoleInfoList")
    public TableDataInfo selectMonitorPointAndLinePoleInfoList(MonitorPoint monitorPoint)
    {
        startPage();
        List<MonitorPoint> list = monitorPointService.selectMonitorPointAndLinePoleInfoList(monitorPoint);
        return getDataTable(list);
    }
    //===========传感器页面======end======================

    /**
     * 新增温度日志
     */
    @ApiOperation("温度管理-批量新增")
    @Log(title = "批量新增温度日志", businessType = BusinessType.INSERT)
    @PostMapping(value = "/insertBatch")
    public AjaxResult insertBatch(@RequestBody List<DeviceTemperature> deviceTemperatureList)
    {
        return toAjax(deviceTemperatureService.insertBatch(deviceTemperatureList));
    }




/*=================================================================================================================**/
    /**
     * 查询温度日志列表
     */
//    @PreAuthorize("@ss.hasPermi('yanjing:temperature:list')")
//    @ApiOperation("查询温度日志列表")
    @GetMapping("/deviceTemperatureList")
    public TableDataInfo deviceTemperatureList(DeviceTemperature deviceTemperature)
    {
        startPage();
        List<DeviceTemperature> list = deviceTemperatureService.deviceTemperatureList(deviceTemperature);
        return getDataTable(list);
    }

    /**
     * 查询温度日志列表
     */
//    @PreAuthorize("@ss.hasPermi('yanjing:temperature:list')")
//    @ApiOperation("查询温度日志列表")
    @GetMapping("/lineTemperatureList")
    public TableDataInfo lineTemperatureList(LineDevicePointTemperatureReq deviceTemperature)
    {
        startPage();
        List<LineDevicePointTemperatureVo> list = deviceTemperatureService.lineTemperatureList(deviceTemperature);
        return getDataTable(list);
    }
}
